import 'package:flutter/material.dart';

import 'app_popup_container.dart';

class AppBusinessDialog extends StatelessWidget {
  const AppBusinessDialog({
    Key? key,
    required this.image,
    required this.title,
    required this.body,
    this.bottom,
  }) : super(key: key);

  final ImageProvider<Object> image;
  final Widget title;
  final Widget body;
  final Widget? bottom;

  @override
  Widget build(BuildContext context) {
    final ThemeData theme = Theme.of(context);

    return AppPopupContainer(
      alignment: Alignment.center,
      backgroundColor: Colors.transparent,
      widthFactor: 263 / 375,
      child: Stack(
        children: <Widget>[
          Container(
            padding: const EdgeInsets.fromLTRB(16, 121, 16, 20),
            decoration: BoxDecoration(
              color: theme.dialogBackgroundColor,
              borderRadius: const BorderRadius.all(Radius.circular(12)),
            ),
            margin: const EdgeInsets.only(top: 16),
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: <Widget>[
                DefaultTextStyle.merge(
                  style: const TextStyle(
                    fontSize: 16,
                    fontWeight: FontWeight.w600,
                    height: 23 / 16,
                  ),
                  child: title,
                ),
                const SizedBox(height: 8),
                ConstrainedBox(
                  constraints: const BoxConstraints(maxHeight: 154),
                  child: Scrollbar(
                    isAlwaysShown: true,
                    child: SingleChildScrollView(
                      child: DefaultTextStyle.merge(
                        style: const TextStyle(
                          fontSize: 12,
                          height: 22 / 12,
                        ),
                        child: body,
                      ),
                    ),
                  ),
                ),
                if (bottom != null) const SizedBox(height: 16),
                if (bottom != null) bottom!,
              ],
            ),
          ),
          SizedBox(
            width: double.infinity,
            child: Image(
              image: image,
              fit: BoxFit.fitWidth,
            ),
          ),
        ],
      ),
    );
  }
}
